<template>
  <div class="container">
    <div class="header">
      <h1>用户列表</h1>
      <el-button @click="loadData">加载数据</el-button>
    </div>
    <div class="user-list">
      <div class="user-item" v-for="item in data" :key="item.userId">
        <div class="user-info">
          <div class="user-name">{{ item.userName }}</div>
          <div class="user-phone">{{ item.phone }}</div>
          <div class="user-birthday">{{ item.birthday }}</div>
          <div class="user-sex">{{ item.sex === 1 ? '男' : '女' }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, reactive, getCurrentInstance, nextTick } from "vue";

const { proxy } = getCurrentInstance();
const data = ref([]);

const loadData = async () => {
  const result = await proxy.Request({
    url: 'userInfo/loadDataList'
  });
  if (!result) {
    return
  }
  data.value = result.data.list;
};
</script>
<style scoped>
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.user-item {
  width: 200px;
  margin: 10px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.user-info {
  margin-bottom: 10px;
}

.user-name {
  font-size: 18px;
  font-weight: bold;
}

.user-phone {
  color: #666;
}

.user-birthday {
  color: #999;
}

.user-sex {
  color: #999;
}

.user-roles {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.user-roles span {
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 3px;
  margin: 5px;
}
</style>
